<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
		<meta charset="utf-8" />
	<link href="css/style.css" rel="stylesheet" type="text/css" />

</head>
<body>
<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li><a href="#">实习过程管理</a></li>
    <li><a href="#">学生实习分配</a></li>
    </ul>
    </div>
    <div class="rightinfo">
    <div class="tools">
    <form id="searchForm" class="form-search" action="jobStudent/jobStudent_page_list.do" method="post">
    	<ul class="seachform1">
    	<c:if test="${userRole <=2 }">
    		<li>选择院系：</li>
    	    <li>
    	    <select id="dpselect" name="XY" class="chosen-select col-xs-10 col-sm-5" onchange="selectChanged();">
						<option value="" > -- 全部 -- </option>
						<c:forEach items="${departmentInfoList}" var="departmentInfo">
							<option value="${departmentInfo.XYMC }" <c:if test="${departmentInfo.XYMC == XY }">selected</c:if> >${departmentInfo.XYMC }</option>
						</c:forEach>
					</select>
    	</li>
    	</c:if>
    	<c:if test="${userRole >2 }">
    	<li><input value="${departmentName }" name="XY" type="hidden">${departmentName } </li>
    	</c:if>
    	<c:if test="${userRole <=3 }">
		<li>选择专业：</li>  
    	<li>
    		<select name="ZYDM" id="ZYDM" class="chosen-select col-xs-10 col-sm-5" onchange="professionInfoChanged();">
						<option value="" > -- 全部 -- </option>
						<c:forEach items="${professionInfoList}" var="professionInfo">
							<option value="${professionInfo.ZYDM }" <c:if test="${professionInfo.ZYDM == ZYDM }">selected</c:if> >${professionInfo.ZYMC }</option>
						</c:forEach>
					</select>
    	</li>
    	</c:if>
    	<c:if test="${userRole >3 }">
    	<li><input value="" name="ZYDM" type="hidden"> </li>
    	</c:if>
    	<li>选择班级：</li>  
    	<li>
    		<select name="XZB" id="XZB" class="chosen-select col-xs-10 col-sm-5" >
						<option value="" > -- 全部 -- </option>
						<c:forEach items="${bjdmbList}" var="bjdmb">
							<option value="${bjdmb.BJMC }" <c:if test="${bjdmb.BJMC == XZB }">selected</c:if> >${bjdmb.BJMC }</option>
						</c:forEach>
					</select>
    	</li>
    	<li>选择年级：</li>  
    	<li>
    		<select name="DQSZJ" id="DQSZJ" >
     		<option value="0" > -- 全部 -- </option>
						<c:forEach items="${gradeList}" var="grade">
							<option value="${grade }" >${grade}</option>
						</c:forEach>
       </select>
    	</li>
    	  <li>是否分配：</li>  
       <li>
    		<select name="state" >
            <c:forEach items="${getDistributionList}" var="distribution">
						<option value="${distribution.id }" <c:if test="${distribution.id ==state }">selected</c:if> >${distribution.name } </option>
						</c:forEach>
       </select>
    	</li>
		<li><input name="XM" type="text" class="scinput1" value="${ XM }" placeholder="输入学生姓名" /></li>
		<li><input name="" type="button" class="scbtn" id="btnSearch" value="查询"/></li>  
		<input type="hidden" name="pageNumber" value="1" />  
		<div class="clearfix"></div>
		</ul>	
    	</form>
    	<!--<ul class="toolbar">
        <li class="click"><span><img src="images/t01.png" /></span>添加</li>
        <li class="click"><span><img src="images/t02.png" /></span>修改</li>
        <li><span><img src="images/t03.png" /></span>删除</li>
        <li><span><img src="images/t04.png" /></span>统计</li>
        </ul>
        <ul class="toolbar1">
        <li><span><img src="images/t05.png" /></span>设置</li>
        </ul>
    -->
    </div>
    <table class="tablelist">
    	<thead>
    	<tr>
        <th>姓名</th>
        <th>班级</th>
        <th>状态</th>
		<th>实习时间</th>
        <th>实习岗位</th>
       <th>实习企业</th>
       <th>学校指导教师</th>
       <th>企业指导教师</th>
       <th>操作</th>
      </tr>
        </thead>
        <tbody>
          <c:forEach items="${jobStudentList}" var="jobStudent"  varStatus="status">
         <tr>
			<td>${jobStudent.XM}</td>
			<td>${jobStudent.XZB}</td>
		 <td><c:if test="${jobStudent.status==0}">在校</c:if>
			<c:if test="${jobStudent.status==1}">自主创业</c:if>
			<c:if test="${jobStudent.status==2}">专升本</c:if>
			<c:if test="${jobStudent.status==3}">自寻企业实习</c:if>
			<c:if test="${jobStudent.status==4}">学校分配企业</c:if>  </td>
  			<td>
  			<c:if test="${ jobStudent.startTime != null }"> ${jobStudent.startTime}至${jobStudent.endTime}</c:if></td> 
  			 <td>${jobStudent.jobName}</td>
			<td>${jobStudent.enterpriseName}</td>
			<td>${jobStudent.schTeacherName}</td>
  			<td>${jobStudent.enterTeacherName}</td> 
			<td><c:if test="${jobStudent.status==0}">
			<a class="sxfp" onclick="distribution(${jobStudent.XH});">实习分配</a>&nbsp;&nbsp;&nbsp;&nbsp;
			</a></c:if></td>
   </tr>
      </c:forEach>
        </tbody>
    </table>
    <div class="pagin">
    	<%@ include file="page.jsp"%>
    </div>
    </div>
   <script src="js/jquery-1.7.2.js"></script>
    <script src="layer/layer.js"></script>
    <script type="text/javascript">
    $('.tablelist tbody tr:odd').addClass('odd');
	$( "#btnSearch" ).on('click', function(e) {
		$("#searchForm").submit();
	});
	function GoToPage(toPage,totalPage) {
	    if(toPage<=0) return;
	    if(toPage>totalPage) return;
	    $("input[name='pageNumber']").val(toPage);
	    $("#searchForm").submit();
	};
	function selectChanged() {
		 var ele=document.getElementById('dpselect');
  	  	var index=ele.selectedIndex;
  	 	 var val=ele.options[index].value;
  	 	$.ajax({
			type: "POST",
			url: "jobStudent/departmentInfo.do",
			data: { XYMC : val},
			async: true,
			dataType: "json",
			success: function(data) {
				$("#ZYDM").empty();
				var all="<option value='' >-- 全部 -- </option>";
				for(var i in data.professionInfoList){  
					var $str = "<option value="+data.professionInfoList[i].ZYDM +">"+data.professionInfoList[i].ZYMC +"</option>";
					$("#ZYDM").append($str);  	 
				}
				$("#ZYDM").append(all);  
				$("#XZB").empty();
				for(var i in data.bjdmbList){  
					var $str = "<option value="+data.bjdmbList[i].BJMC +">"+data.bjdmbList[i].BJMC +"</option>";
					$("#XZB").append($str);
				}
				$("#XZB").append(all);
			}
			})
	}
	function professionInfoChanged() {
		 var ele=document.getElementById('ZYDM');
 	  	var index=ele.selectedIndex;
 	 	 var val=ele.options[index].value;
 	 	 var ele1=document.getElementById('dpselect');
   	  	var index1=ele1.selectedIndex;
   	 	 var val1=ele1.options[index1].value;
 	 	$.ajax({
			type: "POST",
			url: "jobStudent/professionInfo.do",
			data: { ZYDM : val,XYMC : val1},
			async: true,
			dataType: "json",
			success: function(data) {
				var all="<option value='' >-- 全部 -- </option>";
					$("#XZB").empty();
				for(var i in data.bjdmbList){  
					var $str = "<option value="+data.bjdmbList[i].BJMC +">"+data.bjdmbList[i].BJMC +"</option>";
					$("#XZB").append($str);
				}
				$("#XZB").append(all);
			}
			})
	}
	
	function closeAll() {
		layer.alert('分配成功!', {
			skin : 'layer-ext-moon'
		}, function() {
			layer.closeAll(); 
			 location.reload();
		}); 
	}
	function distribution(XH){
	layer.open({
  type: 2,
    closeBtn: 2,
  title: '实习分配',
  shadeClose: true,
  shade: 0.8,
  area: ['600px', '500px'],
  content:'jobStudent/distribution.do?XH='+XH, 
  
  //iframe的url
}); 
	
	}

	
	</script>

</body>

</html>
